package com.spring.test.config;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class UserAware implements BeanNameAware, ApplicationContextAware {
	private String id;
	private String name;
	private String address;
	private ApplicationContext applicationContext;

	//通过感知，获取到了bean的id，如果不实现aware接口，就拿不到这个值
	@Override
	public void setBeanName(String beanName) {
		//ID保存BeanName的值
		id = beanName;
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}
}
